<?php  if ( ! defined('BASEPATH')) exit('No direct script access allowed');?>
<div class="middle padtop10 myclear">
	<div class="page-content">
		
		<!-- bread crumb -->
		<p id="bread-crumb">
			<a href="<?php echo base_url();?>"><?php echo $lang['home']?></a>
			<a href="<?php echo site_url('user/listgroup');?>"><?php echo $lang['agency']?></a>
			<?php echo $group['groupname']?>
		</p><!-- end bread crumb -->
		
		<h3>
			<?php echo $lang['edit'].': '.$group['groupname']?>
		</h3>
		<br style="clear:both;" />
		
		<?php
		$msg = trim($this->input->get('msg',true));
		if($msg != ''){
		?>
		<p class="msg"><?php echo $msg;?></p>
		<br />
		<?php }?>
		
		<div id="tabs">
			<form name="addGroup" action="<?php echo site_url('user/savegroup')?>" method="post" onsubmit="return checkSubmit();">
				<div id="info" style="float:left;width:50%">
				<p class="login-label">
					<?php echo $lang['groupname']?>: <span class="require">*</span>
				</p>
				<p class="padbottom2">
					<input type="text" class="login-input" name="groupname" id="groupname" value="<?php echo $group['groupname']?>" />
				</p>
				
				<p class="login-label padtop10"">
					<?php echo $lang['discount']?>:
					<input type="text" class="login-input" name="discount" id="discount" value="<?php echo number_format($group['discounts'])?>" style="width:80px;display:inline" />
				</p>
				
				<p class="login-label padtop10">
					<?php echo $lang['type_group']?>: &nbsp; &nbsp; &nbsp; &nbsp;
					<select name="typegroup">
						<option value="0"><?php echo $lang['online'];?></option>
						<option value="1" <?php if((int)$group['typegroup'] == 1) echo 'selected="selected"';?>><?php echo $lang['internal'];?></option>
						<option value="2" <?php if((int)$group['typegroup'] == 2) echo 'selected="selected"';?>><?php echo $lang['external'];?></option>
					</select>
				</p>
				
				<p class="login-label padtop10">
					<?php echo $lang['allow_free']?>: &nbsp; &nbsp; &nbsp; &nbsp;&nbsp;&nbsp;
					<label for="allowfree1">
						<input type="radio" <?php if($group['allowfree']==1) echo 'checked="true"'?> name="allowfree" id="allowfree1" value="1" /> <?php echo $lang['tu_duyet']?>
					</label> &nbsp; &nbsp; &nbsp; &nbsp;
					<label for="allowfree0">
						<input type="radio" <?php if($group['allowfree']==0) echo 'checked="true"'?> name="allowfree" id="allowfree0" value="0" /> <?php echo $lang['selfserving']?>
					</label>
				</p>
				
				<p class="login-label padtop10">
					<?php echo $lang['ispostpaid']?>: &nbsp; &nbsp; &nbsp; &nbsp;&nbsp;&nbsp;
					<input type="radio" name="ispostpaid" value="0" <?php if($group['ispostpaid'] == 0) echo 'checked="true"'?> />&nbsp;<?php echo $lang['tratruoc']?>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
					<input type="radio" name="ispostpaid" value="1" <?php if($group['ispostpaid'] == 1) echo 'checked="true"'?> />&nbsp;<?php echo $lang['trasau']?>
				</p>
				
				<p class="login-label padtop10">
					<?php echo $lang['balance'].': &nbsp;'.number_format($group['balance'])?>
				</p>
				<p class="login-label padtop10">
					<?php echo $lang['totalbalance'].': &nbsp;'.number_format($group['totalbalance'])?>
				</p>
				<p class="login-label padtop10">
					<?php echo $lang['promotion'].': &nbsp;'.number_format($group['promotions'])?>
				</p>

				</div>
				<div id="info-agency"  style="float:left">
					<p class="login-label">
						<?php echo $lang['description']?>:
					</p>
					<p class="padbottom2">
						<textarea name="description" cols="35" rows="3"><?php echo $group['description']?></textarea>
					</p>
					
					<p class="login-label padtop10">
						<?php echo $lang['list_zone']?>:
					</p>
					<p class="padbottom2">
						<select name="lstzone[]" id="lstzone" multiple="multiple" style="width:305px;height:130px">
						<?php foreach ($lstZone as $item){?>
							<option value="<?php echo $item['zoneid']?>" title="<?php echo $item['zonename']?>" <?php if(in_array($item['zoneid'],explode(',',$group['lstzone']))) echo 'selected="true"'?>>
								<?php echo $item['zonename']?>
							</option>
						<?php }?>
						</select>
					</p>

				</div><br style="clear:both" />
				<p class="login-label padtop10">
					<input type="hidden" name="groupid" value="<?php echo $group['groupid']?>" />
					<input type="submit" value="<?php echo $lang['save']?>" /> &nbsp;
					<input type="button" value="<?php echo $lang['cancel']?>" onclick="window.location.href='<?php echo site_url('user/listgroup')?>'" />
				</p>
			</form>
		</div>
	</div>
</div>

<script language="javascript">
function checkSubmit()
{
	if($.trim($('#groupname').val()).length == 0)
	{
		alert('<?php echo $lang['enter_groupname']?>');
		$('#groupname').focus();
		return false;
	}

	return true;
}
</script>